package com.fr.thread;

/**
*作者：furong
*日期：2016年9月14日
*时间：上午11:05:40
*/
public class ThreadTest {
    public static void main(String[] args) {

        System.out.println("A2 begin...");
        new A().run();

        System.out.println("A1 begin...");
        new A().start();

        System.out.println("B1 begin...");
        new B().run();
        System.out.println("B1 over...");
        new A().start();

        System.out.println("B1 begin...");
    }

    static class A extends Thread {
        public void run() {
            System.out.println("A begin...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("A over...");
        }
    }

    static class B implements Runnable {

        @Override
        public void run() {
            System.out.println("B begin...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("B over...");

        }

    }

}
